package com.luoguijia.disk.recycle.service.impl;

import com.luoguijia.disk.files.repository.FileDao;
import com.luoguijia.disk.mybatis.entity.PtFileEntity;
import com.luoguijia.disk.mybatis.flexigrid.PagingEntity;
import com.luoguijia.disk.mybatis.flexigrid.TblResponseEntity;
import com.luoguijia.disk.recycle.entity.SearchRecycleEntity;
import com.luoguijia.disk.recycle.repository.RecycleDao;
import com.luoguijia.disk.recycle.service.RecycleService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class RecycleServiceImpl implements RecycleService {

    @Resource
    private RecycleDao recycleDao;
    @Override
    public TblResponseEntity<PtFileEntity> queryRecycleInfoListByPage(SearchRecycleEntity entity, PagingEntity paging) {

        TblResponseEntity<PtFileEntity> tblResponseEntity = new TblResponseEntity<>();
        Integer total = recycleDao.queryRecycleTotal(entity);
        tblResponseEntity.setTotal(total);
        //计算当前页数
        paging.deal(PtFileEntity.class,total);
        tblResponseEntity.setPage(paging.getPage());

        List<PtFileEntity> list = recycleDao.queryRecycleInfoListByPage(entity,paging);
        tblResponseEntity.setRawRecords(list);

        tblResponseEntity.deal();

        return tblResponseEntity;
    }
}
